package com.xmall.controller.admin;

import com.xmall.bean.vo.BaseRespVo;
import com.xmall.bean.table.Topic;
import com.xmall.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("admin/topic")
@RestController
public class TopicController {

    @Autowired
    TopicService topicService;

    @RequestMapping("list")
    public BaseRespVo list(@RequestParam Map<String, String> params){
        Map<String, Object> result = topicService.queryList(params);
        return BaseRespVo.ok(result);
    }

    @RequestMapping("create")
    public BaseRespVo create(@RequestBody Topic create){
        //todo
        create = topicService.createTopic(create);
        return BaseRespVo.ok(create);
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody Topic update){
        update = topicService.updateTopic(update);
        return BaseRespVo.ok(update);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody Topic delete){
        topicService.deleteTopic(delete);
        return BaseRespVo.ok();
    }
}
